package main

import (
	"kra/cmd/gorm/dal/model"

	"gorm.io/driver/mysql"
	"gorm.io/gen"
	"gorm.io/gorm"
)

func main() {

	g := gen.NewGenerator(gen.Config{
		OutPath: "../dal/repository",
		Mode:    gen.WithoutContext | gen.WithDefaultQuery | gen.WithQueryInterface,
	})

	gormdb, _ := gorm.Open(mysql.Open("root:zhyfpwd@tcp(127.0.0.1:3307)/testdb?charset=utf8mb4&parseTime=True&timeout=30s"))
	g.UseDB(gormdb) // reuse your gorm db

	g.ApplyBasic(model.Passport{}, model.User{})

	g.ApplyInterface(func(model.Method) {}, model.User{})
	g.ApplyInterface(func(model.UserMethod) {}, model.User{})

	g.Execute()
}
